<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="../common/common.jsp" %>
<html>
<head>
    <title>分页条页面</title>
    <script type="text/javascript">
        //提交表单frm 偷偷传递一个页码num
        function page_nav(frm, num) {
            frm.pageIndex.value = num;
            frm.submit();
        }

        //提交Go跳转，跳转前要对数字进行有效性验证，如果数字输入正确的，才page_nav()
        function jump_to(frm, pageno) {
            var regexp = /^[1-9]\d*$/;  //只能是数字
            //拿到隐藏域中提交过来的总页数
            var totalPage = document.getElementById("totalPage").value;

            if(!regexp.test(pageno)){
                alert("请输入正确的数字！");
                return false;
            }else if(pageno-totalPage>0){
                alert("总共有"+totalPage+"页，请输入正确的页码！");
                return false;
            }else {
                page_nav(frm, pageno);
            }
        }
    </script>
</head>
<body>
<%
    //分页条页面，所有页面都可以复用我
%>

<div class="page-bar">
    <ul class="page-num-ul clearfix">
        <li>共${param.totalCount}条记录&nbsp;&nbsp; ${param.pageIndex}/${param.totalPage}页</li>&nbsp;&nbsp;
        <c:if test="${param.pageIndex>1}">
        <a href="javascript:page_nav(document.forms[0],'1');">【首页】</a>
        <a href="javascript:page_nav(document.forms[0],'${param.pageIndex-1}');">&lt;上一页</a>
        </c:if>
        <c:if test="${param.pageIndex<param.totalPage}">
        <a href="javascript:page_nav(document.forms[0],'${param.pageIndex+1}');">下一页&gt;</a>
        <a href="javascript:page_nav(document.forms[0],'${param.totalPage}');">【末页】</a>
        </c:if>
        &nbsp;&nbsp;
    </ul>
		 <span class="page-go-form">
             <label>
                 跳转至<input type="text" name="inputPage" id="inputPage" class="page-key" />页
             </label>
	     <button type="button" class="page-btn" onClick='jump_to(document.forms[0],document.getElementById("inputPage").value)'>GO</button>
		</span>
</div>
</body>
</html>
